﻿namespace EasyCMS.Core
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Practices.Unity;
    using Microsoft.Practices.Unity.Configuration;
    using System.Configuration;
    using Pismire;

    public class Comments : EasyCMS.Common.IComments
    {
        #region Dal
        /// <summary>
        /// 通过依赖注入确定使用的数据源
        /// </summary>
        internal Dals.IComment Dal
        {
            get
            {
                lock (syncDal)
                {
                    if (!m_DalList.ContainsKey(DataProviderName))
                    {
                        EasyCMS.Core.Dals.IComment dal = EasyCMS.Common.Runtime.ObjectContainer.Resolve<EasyCMS.Core.Dals.IComment>(DataProviderName);
                        dal.Init(DataProviderArgs);

                        m_DalList.Add(DataProviderName, dal);
                    }
                }
                return m_DalList[DataProviderName];
            }
        }
        private System.Collections.Generic.Dictionary<string, EasyCMS.Core.Dals.IComment> m_DalList = new Dictionary<string, EasyCMS.Core.Dals.IComment>();
        private object syncDal = new object();
        #endregion

        #region IComments 成员

        public string DataProviderName { get; private set; }

        public string DataProviderArgs { get; private set; }

        public void Setup(string dataProviderName, string dataProviderArgs)
        {
            this.DataProviderName = dataProviderName;
            this.DataProviderArgs = dataProviderArgs;
        }

        public EasyCMS.Common.DataComponents.Comment GetByID(int id)
        {
            throw new NotImplementedException();
        }

        public List<EasyCMS.Common.DataComponents.Comment> GetList(EasyCMS.Common.Querys.Comment query)
        {
            throw new NotImplementedException();
        }

        public List<EasyCMS.Common.DataComponents.Comment> GetList(EasyCMS.Common.Querys.Comment query, out int recordCount)
        {
            throw new NotImplementedException();
        }

        public ExcuteState Add(ref EasyCMS.Common.DataComponents.Comment comment)
        {
            throw new NotImplementedException();
        }

        public ExcuteState Update(ref EasyCMS.Common.DataComponents.Comment comment)
        {
            throw new NotImplementedException();
        }

        public ExcuteState Delete(int id)
        {
            throw new NotImplementedException();
        }

        public ExcuteState CreateCommentTable(string partitionMark)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
